package com.designpattern.AbstractFactoryPattern;

/**
 * @Author yp
 * @Date 2021-05-28
 * @Description 抽象工厂
 **/

public class Test {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {

        // 反射+抽象工厂
        String className = "com.designpattern.AbstractFactoryPattern.ZGfarm";//这个可以通过配置文件方式实现
        Class farmType = Class.forName(className);
        Farm farm = (Farm) farmType.newInstance();

//        Farm farm = new ZGfarm();//如果这里是new ZGfarm() 那么不确定什么时候就要new MGfarm()了。
        farm.createAnimal().show();
        farm.createtPlant().show();

    }
}
